<template>
	<view class="">
		<view v-if="meiyi_userinfo.permission.indexOf('add_banjifengcai')!=-1" @click="fabu" style="position:fixed;top: 150rpx;z-index: 100; right: 50rpx;border-radius: 50%;background-color: blue;display: flex;justify-content: center;align-items: center;width: 100rpx;height: 100rpx;">
			<image style="width: 80rpx;height: 80rpx;" src="../../static/10.png" mode=""></image>
		</view>
		<view style="display: flex;width: 700rpx;margin: 10rpx auto;flex-direction: column;font-size: 28rpx;">
			<view v-for="(item,index) in fengcailist" :key="index"  style="letter-spacing: 3rpx;margin-bottom: 40rpx;" >
				<view v-if="fengcailist.length" style="display:flex;flex:row;">
					<view class="">
						<image style="border-radius: 10rpx;margin-right: 20rpx; width: 80rpx;height: 80rpx;" :src="item.avatar" mode=""></image>
					</view>
					<view style="width: 600rpx;overflow: hidden;">
						<view style="color: darkred;font-size: 35rpx;font-weight: 600;">
							{{item.name}}
						</view>
						<view style="margin: 10rpx 0 20rpx 0;">
							{{item.neirong}}
						</view>
						<view  style="display: flex;flex-direction: row;flex-wrap: wrap;" >
							<view v-for="(item1, index1) in item.tupianurl" :key="index1"  style="display: flex;overflow: hidden;">
								<image style="width: 190rpx;height: 190rpx;margin-right: 10rpx;margin-bottom: 10rpx;" :src="item1.path" mode="aspectFill"  @click.stop="prviewImage(item,index)"></image>
							</view>
						</view>
						<view style="display: flex;flex-direction: row;align-items: center;">
							<view style="color: darkgray;margin-right: 30rpx;font-size: 25rpx;">
								<uni-dateformat :date="item.fabudate" format="MM月dd hh:mm" :threshold="[60000,3600000*24*30]" />
							</view>
							<view @click="delfengcai(item)" v-if="item.huiyuanid[0]._id==meiyi_userinfo.uid || meiyi_userinfo.permission.indexOf('del_banjifengcai')!=-1" class="">	
								<u-icon name="close-circle" size="14"></u-icon>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data(){
			return{
				meiyi_userinfo:{
					permission:[]
				},
				fengcailist:[],
				urls:[]//图片预览时使用
				
			}
		},
		async onLoad() {
			this.meiyi_userinfo=await uniCloud.getCurrentUserInfo()
			this.fengcai()
		},
		methods: {
			delfengcai(e){
				uni.showModal({
						title: '重要提示',
						content: '再次确认，一定要删除吗？再次确认，一定要删除吗？再次确认，一定要删除吗？再次确认，一定要删除吗？再次确认，一定要删除吗？再次确认，一定要删除吗？',
						showCancel: true,
						cancelText: '取消',
						confirmText: '确定',
						success: res => {
							if (res.confirm) {
								uni.showLoading({
									title: '删除中…',
									mask: true
								});
								if(e.huiyuanid[0]._id==this.meiyi_userinfo.uid || this.meiyi_userinfo.permission.indexOf('del_banjifengcai')!=-1){
									uniCloud.callFunction({
										name:"funshare",
										data:{
											leixing:15,//类型为15时，删除风采展示
											_id:e._id,
										}
									}).then(res=>{
										this.fengcai()
										uni.showToast({
											title: '删除成功！',
											icon: 'none',
											duration: 1000
										})
										uni.hideLoading()
									})
								}else{
									uni.showToast({
										title: '只能删除自己的发布！',
										icon: 'none',
										duration: 1000
									})
									uni.hideLoading()
								}
							}
						},
						fail: () => {},
						complete: () => {}
					});
				
				
			},
			fabu(){
				uni.navigateTo({
					url: '/pages/fabu/fabu'
				});
			},
			// 图片预览
			prviewImage(img, index) {
				img.tupianurl.forEach(i => {
					this.urls.push(i.path)
				})
				uni.previewImage({
					urls: this.urls,
					current: index
				});
			},
			fengcai(){
				uni.showLoading({
					title: '加载中…',
					mask: true
				});
				uniCloud.callFunction({
					name:"fengcaizhanshi",
				}).then(res=>{
					uni.hideLoading()
					this.fengcailist = res.result.res.data
					for(let i=0;i<this.fengcailist.length;i++){
						this.fengcailist[i].name=this.fengcailist[i].huiyuanid[0].name
						this.fengcailist[i].avatar=this.fengcailist[i].huiyuanid[0].avatar
						this.fengcailist[i].tupianurl=this.fengcailist[i].huiyuanid[0].tupianurl
					}
				})
			}
		}
	}
</script>

<style>

</style>
